// Copyright (C) 2017 Caio Lima. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
description: Invalid String into BigInt constructor should throw SyntaxError
esid: sec-string-to-bigint
info: |
  ToBigInt ( argument )

  String:

  Let n be StringToBigInt(prim).
  If n is NaN, throw a SyntaxError exception.
  Return n.

  StringToBigInt ( argument )

  Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow Infinity, decimal points, or exponents.

features: [BigInt]
---*/

function Test() {
    assert.throws(SyntaxError, function() {
      BigInt("10n");
    });

    assert.throws(SyntaxError, function() {
      BigInt("10x");
    });

    assert.throws(SyntaxError, function() {
      BigInt("10b");
    });

    assert.throws(SyntaxError, function() {
      BigInt("10.5");
    });

    assert.throws(SyntaxError, function() {
      BigInt("0b");
    });

    assert.throws(SyntaxError, function() {
      BigInt("-0x1");
    });

    assert.throws(SyntaxError, function() {
      BigInt("-0XFFab");
    });

    assert.throws(SyntaxError, function() {
      BigInt("0oa");
    });

    assert.throws(SyntaxError, function() {
      BigInt("000 12");
    });

    assert.throws(SyntaxError, function() {
      BigInt("0o");
    });

    assert.throws(SyntaxError, function() {
      BigInt("0x");
    });

    assert.throws(SyntaxError, function() {
      BigInt("00o");
    });

    assert.throws(SyntaxError, function() {
      BigInt("00b");
    });

    assert.throws(SyntaxError, function() {
      BigInt("00x");
    });
}

// preheat
const NUMBER_OF_PREHEAT = 1;
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}

ArkTools.jitCompileAsync(Test);
assert.sameValue(ArkTools.waitJitCompileFinish(Test), true, '[JIT] JIT disabled.');

// test
const NUMBER_OF_TEST = 1; // or 2
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}
